{include file="public/header" /}
<body class="gray-bg">
    <div class="wrapper wrapper-content">

             <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                       <button type="button" class="btn btn-primary btn-outline" onclick="func1()" >添加新闻</button> 
                    </div>
                    <div class="ibox-content">

                        <table class="table table-striped table-bordered table-hover dataTables-example">
                            <thead>
                                <tr>
                                    <th class="text-center">ID</th>
                                    <th class="text-center">标题</th>
									<th class="text-center">排序</th>
									<th class="text-center">时间</th>
									<th class="text-center">操作</th>
                                </tr>
                            </thead>
                            <tbody>
                              {foreach name="new_list" item="vo"}
							<tr class="text-center">
								<td class="text-center">{$vo.id}</td>
								<td>
								{$vo.title}
							</td>
							<td class="text-center">
								{$vo.sort}
							</td>
							<td class="text-center">
								{$vo.add_time}
							</td>
								<td class="text-center">    
                                    <a href="{:url('update_new',['id'=>$vo.id])}" class="btn btn-primary btn-outline btn-xs">
                                     <i class="fa fa-paste"></i> 编辑</a>&nbsp;&nbsp;
                                    <a href="javascript:;" onclick="del_new({$vo.id})" class="btn btn-danger btn-outline btn-xs">
                                       <i class="fa fa-trash-o"></i> 删除</a>  
                                </td>
							</tr>
							{/foreach}
                            </tbody>
                        </table>

                    </div>
                </div>
            </div>
        </div>
    </div>
{include file="public/footer" /}
</body>


<script type="text/javascript">

function func1(){
	window.location.href="{:url('add_new')}";
}
//菜单状态
function rule_state(id){
    $.ajax({
			//请求的url
			//注意，如果我们使用路由器的情况下，我们需要设置一下本地服务器的ip地址
			url: 'rule_state',
			//请求的过程中传递过去的参数 json
			data: {
				id:id
			},
			dataType:'json',
			//成功了的回调，并且带有返回值
			success: function(data) {
				if(data.code == 200) {
				layer.msg(data.msg,{icon:1,time:1500,shade: 0.1},function(index){
                    window.location.href="{:url('user/index')}";
                });
				}else{
					layer.msg(res.msg,{icon:0,time:1500,shade: 0.1});
					}
				}
		})
}
/**
 * [del_rule 删除新闻]
 * @param   {[type]}    id [用户id]
 */
function del_new(id){
    layer.confirm('确认删除此新闻?', {icon: 3, title:'提示'}, function(index){
        //do something
        $.getJSON('./del_new', {'id' : id}, function(res){
            if(res.code == 200){
                layer.msg(res.msg,{icon:1,time:1500,shade: 0.1},function(index){
                    window.location.href="{:url('new/index')}";
                });
               
            }else{
                layer.msg(res.msg,{icon:0,time:1500,shade: 0.1});
            }
        });

        layer.close(index);
    })

}
</script>
</html>